package com.example.back.controller;

import com.example.back.dto.req.MedicationTimeEditReq;
import com.example.back.dto.req.MedicationTimeListReq;
import com.example.back.dto.resp.MedicationTimeListResp;
import com.example.back.service.MedicationTimeService;
import com.example.common.support.Result;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 药品用法
 */
@RestController
@Api(tags = "药品用法")
@RequestMapping("/DConfig/MedicationTime")
public class MedicationTimeController {
    @Resource
    private MedicationTimeService medicationTimeService;

    @ApiOperation(value = "获取药品用法列表", notes = "获取药品用法列表")
    @PostMapping(value = "/list")
    public Result<PageInfo<MedicationTimeListResp>> list(@RequestBody MedicationTimeListReq req) {
        return Result.success(medicationTimeService.list(req));
    }

    @ApiOperation(value = "修改和添加药品用法", notes = "修改和添加药品用法")
    @PostMapping(value = "/commitSave")
    public Result<Object> commitSave(@RequestBody MedicationTimeEditReq req) {
        return Result.success(medicationTimeService.commitSave(req));
    }

    @ApiOperation(value = "删除药品用法", notes = "删除药品用法")
    @PostMapping(value = "/commitDel")
    public Result<Object> commitDel(@RequestBody MedicationTimeEditReq req) {
        return Result.success(medicationTimeService.commitDel(req));
    }
}
